package com.vates.curso.dao.imp;

import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Repository;

import com.vates.curso.dao.DataAccessLayerException;
import com.vates.curso.dao.UserDao;
import com.vates.curso.entities.User;


@Repository("userDao")
public class UserDaoImp extends GenericDaoHibernate<User, Long> implements
		UserDao {

	public UserDaoImp(Class<User> user) {
		super(user);

	}
	
	public UserDaoImp() {
		super(User.class);

	}


	Log log = LogFactory.getLog(UserDaoImp.class);

	/**
	 * Insert a new User into the database.
	 * 
	 * @param user
	 */
	public User save(User user) throws DataAccessLayerException {
		return super.save(user);
	}

	/**
	 * Delete a detached User from the database.
	 * 
	 * @param user
	 */
	public void remove(User user) throws DataAccessLayerException {
		super.remove(user.getUserId());
	}

	/**
	 * Updates the state of a detached User.
	 * 
	 * @param user
	 */
	public void update(User user) throws DataAccessLayerException {
		super.save(user);
	}

	/**
	 * Finds all User in the database.
	 * 
	 * @return
	 */
	public List<User> getAll() throws DataAccessLayerException {
		return super.getAll();
	}

	/**
	 * Finds all distinct User in the database.
	 * 
	 * @return
	 */
	public List<User> getAllDistinct() {

		return super.getAllDistinct();

	}

	/**
	 * Finds a User in the database.
	 * 
	 * @return
	 */
	public User get(long id) {
		return super.get(id);
	}

	/**
	 * Return true if a User exist in the database.
	 * 
	 * @return
	 */
	public boolean exists(Long id) {
		return super.exists(id);
	}

	/**
	 * Return a list of Users that exist in the database.
	 * 
	 * @return
	 */
	public List<User> findByNamedQuery(String queryName,
			Map<String, Object> queryParams) {
		return super.findByNamedQuery(queryName, queryParams);
	}

}